function Box(parent, options) {
    options = options || {},
    this.backgroundColor = options.backgroundColor || 'red',
    this.height = options.height || 20,
    this.width = options.width || 20,
    this.x = options.x || 10,
    this.y = options.y || 10,
    this.parent = parent,
    // 创建节点
    this.div = document.createElement('div')
    parent.appendChild(this.div)
    this.init()
    this.random()
}

Box.prototype.init = function() {
    var div = this.div.style
    div.backgroundColor = this.backgroundColor,
    div.height = this.height + 'px',
    div.width = this.width + 'px',
    // 脱离文档流
    div.position = 'absolute'
}
// 随机生成方块位置
Box.prototype.random = function() {
    var x = Tools.getRandom(0, this.parent.offsetWidth - this.width)
    var y = Tools.getRandom(0, this.parent.offsetHeight - this.height)
    this.div.style.left = x + 'px',
    this.div.style.top = y + 'px'
}